import React from 'react';
import {Route, Switch, routerRedux} from 'dva/router';
import dynamic from 'dva/dynamic'

const {ConnectedRouter} = routerRedux;

function RouterConfig({history, app}) {
  const IndexPage = dynamic({
    app,
    component: () => import('../pages/index')
  })
  const UserPage = dynamic({
    app,
    models: () => [import('../models/user')],
    component: () => import('../pages/user')
  })

  const UserLogin = dynamic({
    app,
    models: () => [import('../models/user')],
    component: () => import('../pages/user/login')
  })

  const SysLogin = dynamic({
    app,
    models: () => [import('../models/user')],
    component: () => import('../pages/sys/login')
  })


  return (
    <ConnectedRouter history={history}>
      <Switch>
        <Route path="/" exact component={IndexPage}/>
        <Route path="/user" exact component={UserPage}/>
        <Route path="/user/login" component={UserLogin}/>
        <Route path="/sys/login" component={SysLogin}/>
      </Switch>
    </ConnectedRouter>
  );
}

export default RouterConfig;
